]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
introspect: Add helper to check method call permission
authorJonas Ådahl <jadahl@gmail.com>
Wed, 25 Sep 2019 18:36:28 +0000 (20:36 +0200)
committerJonas Ådahl <jadahl@gmail.com>
Thu, 20 Feb 2020 11:14:55 +0000 (11:14 +0000)
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/757

js/misc/introspect.js

index d12aac69de9b84649ebc84765d8bb98c020835d4..67965f7d405541c4bc460cec4e760bea90362b65 100644 (file)
@@ -119,9 +119,18 @@ var IntrospectService = class {
                 type == Meta.WindowType.UTILITY;
     }
 
+    _isInvocationAllowed(invocation) {
+        if (this._isIntrospectEnabled())
+            return true;
+
+        if (this._isSenderWhitelisted(invocation.get_sender()))
+            return true;
+
+        return false;
+    }
+
     GetRunningApplicationsAsync(params, invocation) {
-        if (!this._isIntrospectEnabled() &&
-            !this._isSenderWhitelisted(invocation.get_sender())) {
+        if (!this._isInvocationAllowed(invocation)) {
             invocation.return_error_literal(Gio.DBusError,
                                             Gio.DBusError.ACCESS_DENIED,
                                             'App introspection not allowed');
@@ -136,8 +145,7 @@ var IntrospectService = class {
         let apps = this._appSystem.get_running();
         let windowsList = {};
 
-        if (!this._isIntrospectEnabled() &&
-            !this._isSenderWhitelisted(invocation.get_sender())) {
+        if (!this._isInvocationAllowed(invocation)) {
             invocation.return_error_literal(Gio.DBusError,
                                             Gio.DBusError.ACCESS_DENIED,
                                             'App introspection not allowed');